<template>
  <div>
    <el-dialog :title="title" :visible.sync="visible" width="1200px" append-to-body custom-class="import-dialog">
      <el-form ref="form" :model="form">
        <el-form-item label="">
          <el-input type="textarea" v-model="form.supplementaryTerms" placeholder="请输入补充条款" :rows="10"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">保 存</el-button>
        <el-button @click="close">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { debounce } from '@/utils'

export default {
  name: 'upload-contract-scan',
  props: {
    title: {
      type: String,
      default: '补充条款'
    },
    value: {
      type: Boolean,
      default: false
    },
    data:{
      // type: Array,
      default: []
    }
  },
  data() {
    return {
      form: {
        supplementaryTerms: ''
      }
    }
  },
  computed: {
    visible: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('input', val)   // 此处监测visible目的为关闭弹窗时，重新更换value值，注意emit的事件一定要为input。
      }
    }
  },
  watch: {
    value(newVal, oldVal) {
      if (newVal) {
        this.init()
      }
    }
  },
  methods: {
    init() {
      this.form.supplementaryTerms = this.data
    },
    submit: debounce(function() {
      this.$emit('update:data',this.form.supplementaryTerms)
      this.close()
    }, 500,true),
    close() {
      console.log('close')
      this.visible = false
    }
  }
}
</script>


<style scoped lang="scss">

</style>
